#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;

char a[1001], b[1001];
int f[1001][1001];
int main() {
	// freopen64("testdata.in", "r", stdin);
	// freopen64("testdata.out", "w", stdout);
	while (scanf("%s %s", a + 1, b + 1) != EOF) {
		for (register unsigned int i = 1; i <= strlen(a + 1); ++i)
			for (register unsigned int j = 1; j <= strlen(b + 1); ++j) {
				f[i][j] = max(f[i][j - 1], f[i - 1][j]);
				if (a[i] == b[j])
					f[i][j] = f[i - 1][j - 1] + 1;
			}
		printf("%d\n", f[strlen(a + 1)][strlen(b + 1)]);
	}
	return 0;
}